<%@ page language="java" contentType="text/html; charset=UTF-8"	 pageEncoding="UTF-8"%>
<%@ include file="../include/laypublic.jsp" %>
<!DOCTYPE html>
<html>
<head>
  <title>对内建安产值确权复制</title>
</head>
<script type="text/html" id="layui-row"  >
    <div class="layui-row" id="{0}" >
        <div class="contract-box" >
            <div class="contract-money">
                <table class="layui-table">
                    <colgroup>
                        <col width="90">
                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="200">
                        <col width="200">
						<col width="200">
                    </colgroup>
                    <thead>
                    <tr>
                        <td>子项名称<input type="hidden" value="{1}"  name="subNames"   /></td>
                        <td class=tg-c >{1}</td>                        
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
						<td></td>
						<td></td>
                    </tr>
                    </thead>
                    <tbody>
                    <tr>
                        <th>序号</th>
                        <th>费用类型</th>
						<th>对内合同价(元)(下浮后)</th>
						<th>申报金额(元)(下浮前)</th>
						<th>当月对内确权金额(元)(下浮前)</th>
						<th>其中:不参与下浮金额（元）</th>
						<th>对内下浮率(%)</th>
						<th>当月对内确权金额(元)(下浮后)</th>
						<th>开累对内确权金额(元)(下浮后)</th>
                    </tr>
                    </tbody>
                    <tbody >
                    <tr id="{0}Row-1" level=1 >
                        <td><span class="label" >1</span><input type="hidden" value="1" name="orderIdxs" /><input type="hidden" value="{0}" name="contractSubIds" /></td>
                        <td  class=tg-c  ><b>建安工程费</b><input type="hidden" value="1" name="feeTypes" /><input type="hidden" value="-1" name="feeSmallTypes" /><input type="hidden" value="{1}"  name="itemNameSub"  class="itemNameSub" /><input type="hidden" value="建安工程费" name="typeNames" class="typeNames" /></td>                        
						<td><input type="text" name="inAfterAmounts" readonly style="border:0px" autocomplete="off" class="layui-input incontractfee" /></td>
						<td><input type="text" name="applyPreAmounts" readonly style="border:0px" autocomplete="off" class="layui-input declaredfee" /></td>
						<td><input type="text" name="monthPreAmounts" readonly style="border:0px" autocomplete="off" class="layui-input incaesurefee" /></td>
						<td><input type="text" name="notDownAmounts" readonly style="border:0px;" autocomplete="off" class="layui-input notdownfee" /></td>
						<td><input type="text" name="inDownRates" readonly style="border:0px" autocomplete="off" class="layui-input indiscount" /></td>
						<td><input type="text" name="monthAfterAmounts" readonly style="border:0px" autocomplete="off" class="layui-input incaesurefeeafter" /></td>
						<td><input type="text" name="addupAfterAmounts" readonly style="border:0px" autocomplete="off" class="layui-input klincaesurefeeafter" />
						<input type="hidden"   class="histroycaesurefeeafter" /></td>
                    </tr>
                    <tr id="sub{0}Row-1.1"  level=2 >
                        <td><span class="label" >1.1</span><input type="hidden" value="1.1" name="orderIdxs" /><input type="hidden" value="{0}" name="contractSubIds" /></td>
                        <td  class=tg-c  ><label>土建</label><input type="hidden" value="1" name="feeTypes" /><input type="hidden" value="{1}" name="itemNameSub"  class="itemNameSub" /><input type="hidden" value="1.1" name="feeSmallTypes" /><input type="hidden" value="土建" name="typeNames"  class="typeNames"  /></td>
						<td><input type="text" name="inAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input  incontractfee" /></td>
						<td><input type="text" name="applyPreAmounts" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input decimal declaredfee" /></td>
						<td><input type="text" name="monthPreAmounts" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input decimal incaesurefee" /></td>
						<td><input type="text" name="notDownAmounts" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal notdownfee" /></td>
						<td><input type="text" name="inDownRates" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input indiscount" /></td>
						<td><input type="text" name="monthAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input incaesurefeeafter" /></td>
						<td><input type="text" name="addupAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input klincaesurefeeafter" />
						<input type="hidden"   class="histroycaesurefeeafter" /></td>                  		
					</tr>
                    <tr id="sub{0}Row-1.2"  level=2 >
                        <td><span class="label">1.2</span> <input type="hidden" value="1.2" name="orderIdxs" /><input type="hidden" value="{0}" name="contractSubIds" /></td>
                        <td  class=tg-c  ><label>安装</label><input type="hidden" value="1" name="feeTypes" /><input type="hidden" value="{1}" name="itemNameSub" class="itemNameSub" /><input type="hidden" value="1.2" name="feeSmallTypes" /><input type="hidden" value="安装" name="typeNames"  class="typeNames" /></td>
						<td><input type="text" name="inAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input  incontractfee" /></td>
						<td><input type="text" name="applyPreAmounts" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input decimal declaredfee" /></td>
						<td><input type="text" name="monthPreAmounts" lay-verify="required|floatNumber"  autocomplete="off" class="layui-input decimal incaesurefee" /></td>
						<td><input type="text" name="notDownAmounts" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal notdownfee" /></td>
						<td><input type="text" name="inDownRates" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input indiscount" /></td>
						<td><input type="text" name="monthAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input incaesurefeeafter" /></td>
						<td><input type="text" name="addupAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input klincaesurefeeafter" />
						<input type="hidden"   class="histroycaesurefeeafter" /></td>  
					</tr>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</script>

<script type="text/html" id="layui-row-tr" >
<tr id="{0}" level={1} >
 <td><span class="label" >{2}</span><input type="hidden" value="{2}" name="orderIdxs" /><input type="hidden" value="{3}" name="contractSubIds" /></td>
 <td><input type="text" maxlength="50" lay-verify="required" value="{4}" autocomplete="off" class="layui-input typeNames" name="typeNames" />
  <input type="hidden" value="{5}" name="feeTypes" class="feeTypes" />
  <input type="hidden" value="{6}" name="feeSmallTypes" class="feeSmallTypes" />
  <input type="hidden" value="{7}" name="itemNameSub" class="itemNameSub" />
 </td>
 <td><input type="text" value="{8}" name="inAfterAmounts" readonly lay-verify="required|floatNumber" autocomplete="off" style="border:0px" class="layui-input incontractfee" /></td>
 <td><input type="text" value="{9}" name="applyPreAmounts" lay-verify="required|floatNumber" maxlength="10" autocomplete="off" class="layui-input decimal declaredfee" /></td>
 <td><input type="text" value="{10}" name="monthPreAmounts" lay-verify="required|floatNumber" maxlength="10" autocomplete="off" class="layui-input decimal incaesurefee" /></td>
 <td><input type="text" value="{11}" name="notDownAmounts" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal notdownfee" /></td>
 <td><input type="text" value="{12}" name="inDownRates" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input indiscount" /></td>
 <td><input type="text" value="{13}" name="monthAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input incaesurefeeafter" /></td>
 <td><input type="text" value="{14}" name="addupAfterAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input klincaesurefeeafter" />
 <input type="hidden" value="{15}"  class="histroycaesurefeeafter" /></td>
</tr>
</script>

<script type="text/html" id="list-mode-tr" >
<tr id="LISTMODERow-{0}" >
<td><span class="label" >{0}</span><input type="hidden" value="{0}" name="showIdxLists" /></td> 
<td><input type="text" value="{1}" name="subNameLists" readonly style="border:0px" lay-verify="required" autocomplete="off" class="layui-input  name" /></td>
<td><input type="text" value="{2}" name="subUnitLists" readonly style="border:0px" lay-verify="required" autocomplete="off" class="layui-input integer unit" /></td>
<td><input type="text" value="{3}" name="cotUnitPriceLists" readonly style="border:0px" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal contractprice" /></td> 
<td><input type="text" value="{4}" name="cotSumPriceLists" readonly style="border:0px" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal contractamount" /></td> 
<td><input type="text" value="{5}" name="applyNumLists" maxlength="10" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal declarednum" /></td> 
<td><input type="text" value="{6}" name="applyAmountLists" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input decimal declaredamount" /></td> 
<td><input type="text" value="{7}" name="sureNumLists" maxlength="10" lay-verify="required|floatNumber" autocomplete="off" class="layui-input decimal incaesurenum" /></td> 	
<td><input type="text" value="{8}" name="monthSureAmountLists" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input decimal samemonthincaesureamount" /></td> 	
<td><input type="text" value="{9}" name="addupSureAmounts" readonly lay-verify="required|floatNumber" style="border:0px" autocomplete="off" class="layui-input decimal kaileiincaesureamount" />
<input type="hidden"  value="{10}" name="hisotryprice" class="hisotryprice"  />
<input type="hidden"  value="0" name="cotNumLists" />
</td> 	
</tr>
</script>
<style>
.contract-price-info legend{
	text-align:left;
	cursor: default;
	width:175px;
}

.list-title{
	display:block;
	width:342px;
	text-align:right;
	left:55px;
	font-size:.89em;
}

.pos-r{
	position: relative;
}
.pos-a{
	position: absolute;
}

.margin-bot10 {
	margin-bottom: 10px;
}

.margin-lt10 {
	margin-left: 10px;
}

.layui-row+.layui-row {
	margin-top: 10px;
}

.tg-l {
	text-align: left;
}

.tg-c {
	text-align: center;
}

.tg-r {
	text-align: right;
}

.contract-list {
	margin-top: 20px;
}

.contract-box {
	width: 100%;
	min-height: 100px;
}

.contract-money {
	width: 94%;
	margin: 0px auto;
}

.contract-money .layui-table {
	margin: 0;
}

.contract-money th {
	text-align: center;
	height: 38px;
}

.contract-money .label {
	display: block;
	width: 45px !important;
	margin-left: 15px;
}

.fieldset {
	margin-top: 5px;
	margin-bottom: 0px
}

.layui-legend {
	background-color: #5fb878;
	font-size: 15px !important;
	width: 140px;
}

.layui-form-item {
	margin-bottom: 5px;
	clear: both;
	*zoom: 1;
}

.layui-form-label {
	width: 160px;
}

.right {
	float: right;
}

.width106 {
	width: 106px;
}

.bankRow+.bankRow {
	border-top: 1px solid #e0e0e0;
	margin-top: 20px;
	padding-top: 20px;
}
</style>
<body>
	<div class="layui-fluid">
		<div class="layui-card">
			<div style="padding-top: 15px;">&nbsp;</div>
			<form class="layui-form" id="addInfo_form" lay-filter="addInfo_form">
				<div class="layui-tab layui-tab-brief" >
					<div class="layui-tab-content">
						<div class="layui-tab-item layui-show">
							
							<fieldset class="layui-elem-field layui-field-title fieldset" id="baseInfo" >
								<legend class="layui-btn layui-legend"
									style="text-align: left; cursor: default;" >项目基础信息 ></legend>
								<div class="layui-form-item">
									<div class="layui-inline">
										<label class="layui-form-label">申请公司</label>
										<div class="layui-input-inline">
											<input type="hidden" name="hrOrgid" value="${bindOrgId}">
											<input type="text" value="${bindOrgName}"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">申请部门</label>
										<div class="layui-input-inline">
											<input type="hidden" name="hrDeptid" value="${bindDeptId}">
											<input type="text" value="${bindDeptName}"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" >申请人</label>
										<div class="layui-input-inline" >
											<input type="hidden" name="hrStaffApplyid"
												value="${SESSION_KEY_USER_DETAIL.hrStaffId }"> <input type="text" name="staffname" value="${SESSION_KEY_USER_DETAIL.realName}" readonly="readonly" style="border: 0px" autocomplete="off"
												class="layui-input" >
										</div>
									</div>
								</div>
								<div class="layui-form-item"  >	
									<div class="layui-inline" >
										<label class="layui-form-label" >合同类型</label>
										<div class="layui-input-inline" >	
											<input type="hidden" name="cotType"  value="${incaeSureVo.cotType}">
											<input type="text" id="add_select_cotType" lay-verify="required"
												<c:if test="${incaeSureVo.cotType == '1'}">value="内部协议"</c:if>
												<c:if test="${incaeSureVo.cotType == '2'}">value="分包合同"</c:if>
												style="border: 0px;width:220px" readonly="readonly"  class="layui-input">									
										</div>
									</div>						
									<div class="layui-inline" >
										<label class="layui-form-label">合同名称</label>
										<div class="layui-input-inline">
											<input type="text" id="cotNameId" name="refContractName" value="${incaeSureVo.refContractName }" style="border: 0px;width:220px" readonly="readonly" class="layui-input">
											<input type="hidden" id="add_select_proId" name="proCodeAndCodes" value="${incaeSureVo.proCode }_${incaeSureVo.refId }_${incaeSureVo.proName }_${incaeSureVo.refContractName }" style="border: 0px;width:220px" readonly="readonly" class="layui-input">
											<input type="hidden" id="id_code" name="sguid" value="${incaeSureVo.id }">
										</div>
									</div>	
									<div class="layui-inline" >
										<label class="layui-form-label" >合同单位名称</label>
										<div class="layui-input-inline" >
											<input type="hidden" id="sgCoopId" name="sgCoopId" value="${incaeSureVo.sgCoopId }">
											<input type="text" id="id_contractUnitName" value="${incaeSureVo.sgCoopName }"
												style="border: 0px;" readonly="readonly" lay-verify="required"
												class="layui-input">																						
										</div>
									</div>									
								</div>
								<div class="layui-form-item"  >										
									<div class="layui-inline">
										<label class="layui-form-label" >项目名称</label>
										<div class="layui-input-inline" >
											<input type="text" id="id_proName" name="proName" value="${incaeSureVo.proName }" style="border: 0px;width:220px"
												readonly="readonly" class="layui-input">
										</div>
									</div>									
									<div class="layui-inline">
										<label class="layui-form-label">项目编号</label>
										<div class="layui-input-inline">
											<input type="text" id="id_proCode" name="proCode" value="${incaeSureVo.proCode }" style="border: 0px;"
												readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label">区域公司</label>
										<div class="layui-input-inline">
											<input type="hidden" id="areaId" name="hrOrgAreaId" value="${incaeSureVo.hrOrgAreaId }">
											<input type="text" id="id_regionalCompany"
												value="${incaeSureVo.orgAreaName }" readonly="readonly"
												style="border: 0px;width:220px" autocomplete="off" class="layui-input">
										</div>
									</div>								
								</div>
								<div class="layui-form-item"  >									
									<div class="layui-inline" >
										<label class="layui-form-label" >项目公司</label>
										<div class="layui-input-inline" >
											<input type="hidden" id="compId" name="hrOrgProId"  value="${incaeSureVo.hrOrgProId }">
											<input type="text" id="id_projectCompany" value="${incaeSureVo.orgProName }"
												style="border: 0px;width:220px" readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline">
										<label class="layui-form-label" >实施机构</label>
										<div class="layui-input-inline" >
											<input type="text" id="id_ImplementingBody" name="carryOrg" style="border: 0px;width:220px"
												value="${incaeSureVo.carryOrg}"  readonly="readonly" class="layui-input">
										</div>
									</div>
									<div class="layui-inline" >
										<label class="layui-form-label" >项目地址</label>
										<div class="layui-input-inline" >
											<input type="hidden" id="sgCityId" name="sgCityId" value="${incaeSureVo.sgCityId}">
											<input type="text" id="id_projectAddress" name="projectAddress" value="${incaeSureVo.sgCityName}"
												style="border: 0px;" readonly="readonly" class="layui-input">
										</div>
									</div>
								</div>
								<div class="layui-form-item"  >
									<div class="layui-inline" >
										<label class="layui-form-label" >项目负责人</label>
										<div class="layui-input-inline" >
											<input type="text" id="id_projectLeader" value="${incaeSureVo.proLeader}" name="proLeader"
												 readonly="readonly" style="border: 0px;" class="layui-input">
										</div>
									</div>
									<div class="layui-inline" >
										<label class="layui-form-label" >确权模式</label>
										<div class="layui-input-inline" >
											<input type="hidden" name="sureType"  value="${incaeSureVo.sureType}">
											<input type="text" id="rightconfirmationmode" lay-verify="required"
												<c:if test="${incaeSureVo.sureType == '1'}">value="整体下浮"</c:if>
												<c:if test="${incaeSureVo.sureType == '2'}">value="清单模式"</c:if>
												style="border: 0px;" readonly="readonly"  class="layui-input">
										</div>
									</div>
									<div class="layui-inline" >
										<label class="layui-form-label" >确权月份</label>
										<div class="layui-input-inline" >
											<input type="text" value="<fmt:formatDate value="${incaeSureVo.sureMonth }" pattern="yyyy-MM"/>" class="layui-input" id="caesureMonth" name="sureMonthStr" lay-verify="required" readonly>
										</div>
									</div>									
								</div>
								<div class="layui-form-item"  >
									<div class="layui-inline" >
										<label class="layui-form-label" >当月对外确权金额（下浮后）（元）</label>
										<div class="layui-input-inline" >
											<input type="text" readonly style="border:0px" name="monthOutAmount"  id="id_monthOutAmount" value="${incaeSureVo.monthOutAmount }" lay-verify="required|floatNumber" class="layui-input" >
										</div>
									</div>
									<div class="layui-inline" >
										<label class="layui-form-label" >开累对外确权金额（下浮后）（元）</label>
										<div class="layui-input-inline" >
											<input type="text" readonly style="border:0px" name="addupOutAmount"  id="id_addupOutAmount" value="${incaeSureVo.addupOutAmount }" lay-verify="required|floatNumber" class="layui-input" >											
										</div>
									</div>
									<div class="layui-inline" >
										<label class="layui-form-label" >当月对内确权金额（下浮后）（元）</label>
										<div class="layui-input-inline">
											<input type="text" readonly style="border:0px" name="monthAfterAmountTotal"  id="id_monthAfterAmount" value="${incaeSureVo.monthAfterAmount }" lay-verify="required|floatNumber" class="layui-input" >
										</div>
									</div>
								</div>
								<div class="layui-form-item">
									<div class="layui-inline" >
										<label class="layui-form-label" >开累对内确权金额（下浮后）（元）</label>
										<div class="layui-input-inline" >
											<input type="text" readonly style="border:0px" name="addupAfterAmountTotal"  id="id_addupAfterAmount" value="${incaeSureVo.addupAfterAmount }" lay-verify="required|floatNumber" class="layui-input" >											
										</div>
									</div>
								</div>				
							</fieldset>
							<fieldset class="layui-elem-field layui-field-title fieldset contract-price-info" <c:if test="${incaeSureVo.sureType == '2'}">style="display:none"</c:if>>
							<input type="hidden" value="0" name="cotSumPrice" readonly style="border:0px;" class="layui-input" />
							<input type="hidden" value="0" name="applyNums" readonly style="border:0px;" class="layui-input" />
							<input type="hidden" value="0" name="applyAmount" readonly style="border:0px;" class="layui-input " />
							<input type="hidden" value="0" name="sureNums" readonly style="border:0px;" class="layui-input " />		    														
								<legend class="layui-btn layui-legend" >确权明细-下浮模式  ></legend>
								<div class="contract-list" >																	
									<div class="contract-box margin-bot10" >
	            						<div class="contract-money">
	                						<table class="layui-table">
							                    <colgroup>
							                        <col width="100"  >
							                        <col width="260"  >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                    </colgroup>
												<thead>
													<tr>
														<th></th>
											            <th>对内合同价(元)(下浮后)</th>
											  			<th>申报金额(元)(下浮前)</th>
														<th>当月对内确权金额(元)(下浮前)</th>
														<th>对内下浮率(%)</th>
														<th>当月对内确权金额(元)(下浮后)</th>
														<th>开累对内确权金额(元)(下浮后)</th>
													</tr>
												</thead>
												<tbody >
													<tr>
													    <td class="tg-r" >合计</td>
														<td><input type="text" value="${incaeSureVo.inAfterAmount}" id="incontractfee" style="border:0px" lay-verify="required|floatNumber" name="inAfterAmount" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.applyPreAmount}" id="declaredfee" style="border:0px" lay-verify="required|floatNumber" name="applyPreAmount" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.monthPreAmount}" id="incaesurefee" style="border:0px" lay-verify="required|floatNumber" name="monthPreAmount" readonly autocomplete="off" class="layui-input " />
															<input type="hidden" value="0" id="notdownfee" style="border:0px;" lay-verify="required|floatNumber" name="notDownAmount" readonly autocomplete="off" class="layui-input " />
														</td>
														<td><input type="text" value="${incaeSureVo.inDownRate}" id="indiscount" style="border:0px" lay-verify="required|floatNumber" name="inDownRate" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.monthAfterAmount}" id="incaesurefeeafter" style="border:0px" lay-verify="required|floatNumber" name="monthAfterAmount" readonly autocomplete="off" class="layui-input" /></td>
														<td><input type="text" value="${incaeSureVo.addupAfterAmount}" id="klincaesurefeeafter" style="border:0px" lay-verify="required|floatNumber" name="addupAfterAmount" readonly autocomplete="off" class="layui-input" /></td>													
													</tr>
								                </tbody>
							                </table>
	                    				</div>
                    				</div> 							
								</div>
							</fieldset>
										
							<fieldset class="layui-elem-field layui-field-title fieldset contract-price-info" <c:if test="${incaeSureVo.sureType == '1'}">style="display:none"</c:if> >
							<input type="hidden" value="0" name="inAfterAmount" readonly style="border:0px;" class="layui-input" />
							<input type="hidden" value="0" name="applyPreAmount" readonly style="border:0px;" class="layui-input" />
							<input type="hidden" value="0" name="monthPreAmount" readonly style="border:0px;" class="layui-input " />
							<input type="hidden" value="0" name="notDownAmount" readonly style="border:0px;" class="layui-input " />
							<input type="hidden" value="0" name="inDownRate" readonly style="border:0px;" class="layui-input " />		    	
							    <legend class="layui-btn layui-legend" >确权明细-清单模式  ></legend>
							    	<div style="height:20px;">&nbsp;</div>																
									<div class="contract-box margin-bot10" >
	            						<div class="contract-money" >
	            						    <table class="layui-table" >
							                    <colgroup>
							                        <col width="100" >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                        <col width="290" >
							                    </colgroup>
												<thead>
													<tr>
														<th></th>
														<th>合同金额（元）</th>
														<th>申报数量</th>
														<th>申报金额（元）</th>
														<th>对内确权数量</th>
														<th>当月对内确权金额（元）</th>
														<th>开累对内确权金额（元）</th>
													</tr>
												</thead>
												<tbody >
													<tr>
													    <td class="tg-r" >合计</td>
														<td><input type="text" value="${incaeSureVo.cotSumPrice}" id="contractamount" style="border:0px" lay-verify="required|floatNumber" name="cotSumPrice" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.applyNums}" id="declarednum" style="border:0px" lay-verify="required|floatNumber" name="applyNums" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.applyAmount}" id="declaredamount" style="border:0px" lay-verify="required|floatNumber" name="applyAmount" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.sureNums}" id="incaesurenum" style="border:0px" lay-verify="required|floatNumber" name="sureNums" readonly autocomplete="off" class="layui-input " /></td>
														<td><input type="text" value="${incaeSureVo.monthAfterAmount}" id="samemonthincaesureamount" style="border:0px" lay-verify="required|floatNumber" name="monthAfterAmount" readonly autocomplete="off" class="layui-input" /></td>
														<td><input type="text" value="${incaeSureVo.addupAfterAmount}" id="kaileiincaesureamount" style="border:0px" lay-verify="required|floatNumber" name="addupAfterAmount" readonly autocomplete="off" class="layui-input" /></td>													
													</tr>
								                </tbody>
							                </table>	                						
	                    				</div>
                    				</div>																								
									<div class="contract-box " id="list-mode">
	            						<div class="contract-money">
	                						<table class="layui-table">
							                    <colgroup>
							                        <col width="90">
							                        <col width="600">
							                        <col width="300">
							                        <col width="300">
							                        <col width="300">							                        
							                        <col width="300">
							                        <col width="300">
							                        <col width="300">
							                        <col width="300">
							                        <col width="300">
							                    </colgroup>
												<thead>
													<tr>
														<th>序号</th>
														<th>分部分项清单名称</th>
														<th>计量单位</th>
														<th>合同单价(元)</th>
														<th>合同金额（元）</th>
														<th>申报数量</th>
														<th>申报金额（元）</th>
														<th>对内确权数量</th>
														<th>当月对内确权金额（元）</th>														
														<th>开累对内确权金额（元）</th>
													</tr>
												</thead>
												<tbody>																																				
								                </tbody>
							                </table>
	                    				</div>
	                    			</div>                                       		                    										
							</fieldset>										
							<fieldset class="layui-elem-field layui-field-title fieldset" id="baseInfo" >
								<legend class="layui-btn layui-legend" style="text-align: left; cursor: default;" >附件 ></legend>
								<div style="margin-top: 20px;" >
									<div class="layui-form-item" >
										<label class="layui-form-label" style="width: 350px;">支持pdf、excel、word、图片资料，可上传多个</label>
									</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">计算稿（选填）</label>
									    <div class="layui-input-block">
									    	<div class="layui-upload">
								              	<button type="button" class="layui-btn" id="1-upload-more">上传</button>
						                		<div class="layui-upload-list" id="1-upload-more-list">
						                			<c:forEach items="${incaeSureVo.incaeSureAtts }" var="fileAtt">
								              			<c:if test="${fileAtt.types == '11' }">
								              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
								              					<c:choose>
									              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
										              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
										              				</c:when>
										              				<c:otherwise>
										              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
										              				</c:otherwise>
								              					</c:choose>
								              					<div class="mask">
								              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
								              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
								              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtts1" ></input>
								              					</div>
								              					<p>${fileAtt.fileName}</p>
								              				</div>
								              			</c:if>
								              		</c:forEach>
						                		</div>
								            </div>
									    </div>
								  	</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">签字扫描件（选填）</label>
									    <div class="layui-input-block">
									    	<div class="layui-upload">
								              	<button type="button" class="layui-btn" id="2-upload-more">上传</button>
						                		<div class="layui-upload-list" id="2-upload-more-list">
						                			<c:forEach items="${incaeSureVo.incaeSureAtts }" var="fileAtt">
								              			<c:if test="${fileAtt.types == '12' }">
								              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
								              					<c:choose>
									              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
										              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
										              				</c:when>
										              				<c:otherwise>
										              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
										              				</c:otherwise>
								              					</c:choose>
								              					<div class="mask">
								              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
								              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
								              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtts2" ></input>
								              					</div>
								              					<p>${fileAtt.fileName}</p>
								              				</div>
								              			</c:if>
								              		</c:forEach>
						                		</div>
								            </div>
									    </div>
								  	</div>
									<div class="layui-form-item">
									    <label class="layui-form-label">其他附件（选填）</label>
									    <div class="layui-input-block">
									    	<div class="layui-upload">
								              	<button type="button" class="layui-btn" id="3-upload-more">上传</button>
						                		<div class="layui-upload-list" id="3-upload-more-list">
						                			<c:forEach items="${incaeSureVo.incaeSureAtts }" var="fileAtt">
								              			<c:if test="${fileAtt.types == '4' }">
								              				<div class="layui-upload-img-div" id="upload_img_${fileAtt.id }">
								              					<c:choose>
									              					<c:when test="${fileAtt.fileSuffix == '.jpg' or fileAtt.fileSuffix == '.jpeg' or fileAtt.fileSuffix == '.png'}">
										              					<img src="${fileHttpPre }/${fileAtt.filePath }" title="${fileAtt.fileName}" class="layui-upload-img">
										              				</c:when>
										              				<c:otherwise>
										              					<img src="${ctx}/resources/images/${fn:substring(fileAtt.fileSuffix,1,5)}.jpg" title="${fileAtt.fileName}" class="layui-upload-img">
										              				</c:otherwise>
								              					</c:choose>
								              					<div class="mask">
								              						<a href="javascript:void(0)" onclick="showImg('${fileHttpPre}/${fileAtt.filePath }');">查看</a>
								              						<a href="javascript:void(0)" onclick="del('${fileAtt.id}')">删除</a>
								              						<input type="hidden" value="${fileAtt.types}|${fileAtt.fileName}${fileAtt.fileSuffix }||${fileAtt.filePath }" id="fileAtt_${fileAtt.id}" name="fileAtts3" ></input>
								              					</div>
								              					<p>${fileAtt.fileName}</p>
								              				</div>
								              			</c:if>
								              		</c:forEach>
						                		</div>
								            </div>
									    </div>
								  	</div>
								</div>
							</fieldset>
						</div>
					</div>
				</div>
				<div class="layui-form-item"
					style="position: fixed ! important; right: 30px; bottom: 45%; z-index: 10000;">
					<div class="layui-input-block">
						<button
							class="layui-btn layui-bg-blue layui-btn-normal layui-btn-lg  layui-btn-radius"
							type="button" lay-submit lay-filter="addInfo_form_submit"
							id="addInfo_form_submit">
							<i class="layui-icon layui-icon-ok layuiadmin-button-btn"></i> 提交
						</button>
					</div>
				</div>
			</form>
		</div>
	</div>
</body>
</html>
<script type="text/javascript"  >
String.prototype.format = function () {
	var model = arguments;
    return this.replace(/\{(\d+)\}/g, function (s, i) { 
    	/* return !!model[i]?model[i]:''; */
        return model[i];
    });
}
String.prototype.toInt = function () {
	if(this==''){
		return 0;
	}
	return parseInt(this);
}
String.prototype.toFloat = function () {
	if(this==''){
		return 0;
	}
	return parseFloat(this);
}
Number.prototype.toMoney = function () {
	var m = Math.pow(10, 2);
	return Math.round(this * m) / m;
}
var getPercentage = function(a, b, d) {
	var quotient = Number(b) != 0 ? a / b : 0;
	if (d == true) {
		return setDecimalPlaces((1 - quotient) * 100, 2);
	}
	return setDecimalPlaces(quotient * 100, 2);
}

var setDecimalPlaces = function(f, digit) {
	var m = Math.pow(10, digit);
	return Math.round(f * m) / m;
}
function parentGroup($, type, id) {
	if(type=="incontractfee"){
		amountParentGroup($, 'incontractfee', id);
		countTopRows($, ['incontractfee']);				
	}
	if(type=="declaredfee"){
		amountParentGroup($, 'declaredfee', id);
		countTopRows($, ['declaredfee']);				
	}
	if(type=="incaesurefee" ||type=="notdownfee"){
		if(type=="incaesurefee"){
			amountParentGroup($, 'incaesurefee', id);
		}else if(type=="notdownfee"){
			amountParentGroup($, 'notdownfee', id);
		}	
		countTopRows($, ['incaesurefee','notdownfee','incaesurefeeafter','klincaesurefeeafter']);
		var incaesurefee = $('#incaesurefee').val();
		var indiscount = $('#indiscount').val();
		var notdownfee =  $('#notdownfee').val();		
		var incaesurefeeafter = notdownfee.toFloat() + (incaesurefee -notdownfee)* (1-indiscount/100);
		//重新计算总当月对内确权金额
		//$('#incaesurefeeafter').val(incaesurefeeafter.toFixed(2));
		//重新计算总开累对内确权金额
		var arr = id.split('.');
		var trId = arr[0].replace('sub', '');
		var $tr = $('[id="' + trId + '"]');
		var klincaesurefeeafter = $("tr[level=1]").find('.histroycaesurefeeafter').inputTotal();
		var newklincaesurefeeafter = incaesurefeeafter + klincaesurefeeafter;
		//$('#klincaesurefeeafter').val(newklincaesurefeeafter.toFixed(2));
		//$('#id_monthAfterAmount').val(incaesurefeeafter.toFixed(2));
		//$('#id_addupAfterAmount').val(newklincaesurefeeafter.toFixed(2));
	}
}
function amountParentGroup($, type, id) {
	var arr = id.split('.');
	if (arr.length == 3) {
		var item = arr.slice(0, 2);
		var trId = item.join('.');				
		var $tr = $('[id="' + trId + '"]');
		$tr.find('.' + type).val($("tr[id^='" + trId + ".'][level=3]").find('.' + type).inputTotal());
		var $childTr  = $("tr[id^='" + trId + ".'][level=3]");
		incaesurefee2(type,$tr,$childTr);
		if(type=="incaesurefee" || type=='notdownfee'){
			var $parentTr = $('[id="' + item[0].replace('sub', '') + '"]');
			$parentTr.find('.' + type).val($("tr[id^='" + item[0] + ".'][level=2]").find('.' + type).inputTotal());
			var $pTr = $("tr[id^='" + item[0] + ".'][level=2]")
			incaesurefee3(type,$parentTr,$pTr);
		}
	}
	if (arr.length >= 2) {
		var trId = arr[0].replace('sub', '');				
		var $tr = $('[id="' + trId + '"]');
		$tr.find('.' + type).val($("tr[id^='" + arr[0] + ".'][level=2]").find('.' + type).inputTotal());
		if(type=="incaesurefee" || type=='notdownfee'){
			var $parentTr = $('[id="' + arr[0].replace('sub', '') + '"]');
			$parentTr.find('.' + type).val($("tr[id^='" + arr[0] + ".'][level=2]").find('.' + type).inputTotal());
			var $pTr = $("tr[id^='" + arr[0] + ".'][level=2]")
			incaesurefee3(type,$parentTr,$pTr);
		}
	}
}
function countTopRows($, types) {
	var $contractListLayuiRow = $('.layui-row');
	types.forEach(function(e) {		
		var $total = $('#' + e);
		var total = $contractListLayuiRow.find("tr[id$='Row-1'] input[type=text]." + e).inputTotal();
		$total.val(total);		
		if(e=='incaesurefeeafter'){
			$('#id_monthAfterAmount').val(total);
		}
		if(e=='klincaesurefeeafter'){
			$('#id_addupAfterAmount').val(total);
		}
	});
}
function eightS4() {
    function S4() {
        return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
    }
    return (S4()+S4()+""+S4()+""+S4()+""+S4()+""+S4()+S4()+S4()).toLocaleUpperCase();
}
function setReadonly($t) {
	if ($t) {
		$t.find('input[type=text].incontractfee').prop('readonly', true).removeAttr('lay-verify');
		$t.find('input[type=text].notdownfee').prop('readonly', true).removeAttr('lay-verify');
		$t.find('input[type=text].declaredfee').prop('readonly', true).removeAttr('lay-verify');
		$t.find('input[type=text].incaesurefee').prop('readonly', true).removeAttr('lay-verify');
	}
}
    var listModeData = [{name:'',unit:'元',contractprice:0,contractamount:0,historyprice:0 }];
	var subList = [];
	var proName;
	var proNameid;
	//静态资源路径前缀
	var staticPath = '${fileHttpPre}';
	var stateJSON = <infopub:dicJson groupNo="A00010028" />;
	layui.config({base : '${ctx}/resources/layuiadmin/' //静态资源所在路径
			})
			.extend({
				index : 'lib/index' //主入口模块
			})
			.use([ 'index', 'set', 'upload', 'element', 'laydate' ], function() {
						var $ = layui.$, form = layui.form, element = layui.element, laydate = layui.laydate, upload = layui.upload;
						// 正则校验
						form.verify({
							//验证汉字
						    CHS:[
						    	/^[\u0391-\uFFE5]+$/
						    	,'只能输入汉字'
						  	],
						  	//名字校验
						  	COC: [
								/^[\u4e00-\u9fa5_a-zA-Z0-9]+$/
								,'请输入正确的名称'
						  	],
						  	//大于0的正整数
						  	intNumber:[
								/^[1-9]\d*$/
								,'请输入正确的数字'
						  	],
						  	//数字只能有两位小数
						  	floatNumber:[
								/^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
								,'请输入正确的数字'
						  	],
						  	telNumber:[/^[1][3,4,5,7,8,9][0-9]{9}$/
								  		,'请输入正确的号码'
							],
						  	//数字大于0，并只能有两位小数
						  	floatAmount:[
								/^([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/
								//var pattern=/^((\d+\.\d*[1-9]\d{1})|(\d*[1-9]\d*\.\d{2}))$/; 
								,'请输入正确的数字'
						  	]
						});
						
						uploadRender(1, upload, $);
						uploadRender(2, upload, $);
						uploadRender(3, upload, $);
						
						laydate.render({ 
							elem: '#caesureMonth'
						    ,type: 'month'
						    ,trigger:'click'
						    ,done: function(value, date){
						    	var incaeSureMonth = value;
						    	var proId = $('#add_select_proId').val();
						  	     $.ajax({
						 			type : "POST", //提交方式  
						 			url : "${ctx}/incaeSure/getMonthAfterAmount",//路径  
						 			data : {
						 				"proCodeAndCodes" : proId,
						 				"sureMonth" : incaeSureMonth
						 			},//数据，这里使用的是Json格式进行传输  
						 			success : function(result) {//返回数据根据结果进行相应的处理 
						 				if (result.flag == true) {
						 					//当月对外确权金额(下浮后)元
											if(result.outcaeSure!=null&&result.outcaeSure!=''){
												$("#id_monthOutAmount").val(result.outcaeSure);						
											}else{
												$("#id_monthOutAmount").val(0);
											}
											//所有月份合计(对外确权金额(下浮后)元)开累对外确权金额（下浮后）
											if(result.monthAfterAmount!=null&&result.monthAfterAmount!=''){
												$("#id_addupOutAmount").val(result.monthAfterAmount);
											}else{
												$("#id_addupOutAmount").val(0);
											}
						 					form.render();
						 				}
						 			}
						 		});	
					  	     
					  	    }
						});
						
						(function($) {
							$.fn.inputTotal = function() {
								var sum = 0;
								this.each(function() {
									var thisNum = $(this);
									var val = !!thisNum.val() ? thisNum.val()
											: 0;
									var num = parseFloat(val);
									sum = setDecimalPlaces(sum + num, 2);
								});
								return sum;
							};
						})($);	
						
						var id = $("#id_code").val();
						$.ajax({
							type : "POST", //提交方式  
							url : "${ctx}/incaeSure/getIncaeSureById",//路径  
							data : { "sguid" : id
							},//数据，这里使用的是Json格式进行传输  
							success : function(result) {//返回数据根据结果进行相应的处理 					
								if (result.flag == true) {
									var layuiRowHtml = $('#layui-row').html();
									var $contractList = $('.contract-list');
									$contractList.find(".layui-row").remove();
									
									var types = result.incaeSureVo.cotType;
									//合同类型为内部协议
									if(types=='1'){										
										//内部协议名称带出确权模式（整体下浮）
										var details =result.incaeSureVo.incaeSureSubVos;
										if(details!=null&&details!=''&&details.length>0){
											var hash = {},subList=[];
											for(var k=0;k<details.length;k++){
												for(var i = 0, j = details[k].incaeSureDetails.length; i < j; i++) {												
													var e = details[k].incaeSureDetails[i];						
													if(typeof(hash[e.sureSubId])=='undefined'){
														hash[e.sureSubId] = subList.length;							
														subList.push({
															subName:details[k].subName,
															sureSubId:e.sureSubId,
															list:[{
																subRowId : e.orderIdx.indexOf(',')!=-1?e.orderIdx.split(',')[1]:e.orderIdx,
																costType : e.typeName.indexOf(',')!=-1?e.typeName.split(',')[1]:e.typeName,
																incontractfee : e.inAfterAmount,
																declaredfee : e.applyPreAmount,
																incaesurefee : e.monthPreAmount,
																notdownfee : e.notDownAmount,
																indiscount : e.inDownRate,
																incaesurefeeafter : e.monthAfterAmount,
																klincaesurefeeafter : e.addupAfterAmount,
																histroycaesurefeeafter : e.addupAfterAmount-e.monthAfterAmount
															}]
														});							

													}else{								
														var index =  hash[e.sureSubId].toString().toInt();
														subList[index].list.push({
															subRowId : e.orderIdx.indexOf(',')!=-1?e.orderIdx.split(',')[1]:e.orderIdx,
															costType : e.typeName.indexOf(',')!=-1?e.typeName.split(',')[1]:e.typeName,
															incontractfee : e.inAfterAmount,
															declaredfee : e.applyPreAmount,
															incaesurefee : e.monthPreAmount,
															notdownfee : e.notDownAmount,
															indiscount : e.inDownRate,
															incaesurefeeafter : e.monthAfterAmount,
															klincaesurefeeafter : e.addupAfterAmount,
															histroycaesurefeeafter : e.addupAfterAmount-e.monthAfterAmount
														});						
													}						
												}
											}
										}
																									
										for (var i = 0, j = subList.length; i < j; i++) {
											var itemNameSub = subList[i].subName,subId = subList[i].sureSubId;
											var tempHtml = layuiRowHtml.format(subId,itemNameSub);
											var $html = $(tempHtml);
											subList[i].list.forEach(function(e) {
												var subRowId = e.subRowId;
												var costType = e.costType;					
												var incontractfee = e.incontractfee;
												var declaredfee = e.declaredfee;
												var incaesurefee = e.incaesurefee;
												var notdownfee = e.notdownfee;
												var indiscount = e.indiscount;
												var incaesurefeeafter = e.incaesurefeeafter;
												var klincaesurefeeafter = e.klincaesurefeeafter;	
												var histroycaesurefeeafter = e.histroycaesurefeeafter;
												
												var $row = $html.find('tr[id$="' + subId + 'Row-' + subRowId + '"]');
												if ($row.length == 1) {
													$row.find('input[type="hidden"]:eq(0)').val(subRowId);
													var $typeNames = $row.find('td:eq(1) input.typeNames');									
													if ($typeNames.val() != costType) {						
														$typeNames.val(costType);								
														var $lastPrev = $typeNames.prevAll(':last');
														$lastPrev.text(costType);
													}							
													$row.find('td:eq(2) input').val(incontractfee);
													$row.find('td:eq(3) input').val(declaredfee);
													$row.find('td:eq(4) input').val(incaesurefee);
													$row.find('td:eq(5) input').val(notdownfee);
													$row.find('td:eq(6) input').val(indiscount);
													$row.find('td:eq(7) input').val(incaesurefeeafter);
													$row.find('td:eq(8) input.klincaesurefeeafter').val(klincaesurefeeafter);
													$row.find('td:eq(8) input.histroycaesurefeeafter').val(histroycaesurefeeafter);
												} else {
													var arr = subRowId.split('.');
													var level = arr.length;
													if (level >= 2) {									
														var id = "sub"+subId+"Row-"+subRowId;												
														var types = subRowId.split('.');        
												        var feeTypes = types[0],feeSmallTypes = types[0]+'.'+types[1];								        												
														var $trHtml = $($('#layui-row-tr').html().format(id,level,subRowId,subId,costType,feeTypes,feeSmallTypes,itemNameSub,
															incontractfee,declaredfee,incaesurefee,notdownfee,indiscount,incaesurefeeafter,klincaesurefeeafter,histroycaesurefeeafter));
														
														var pop = arr.pop();
														var parent = arr.length==1? subId + 'Row-' + arr[0]:"sub" + subId + "Row-" + arr.join('.');								
														var siblings = (parent.indexOf('sub')==-1?'sub':'') + parent + '.';								
														var $parent = $html.find("tr[id='" + parent + "']");
														var $siblings = $html.find("tr[id^='" + siblings + "']");								
														var siblingslen = $siblings.length;							
														setReadonly($parent);
																						
														if (siblingslen > 0) {
															var $last = $($siblings[siblingslen - 1]);
															var lastId = $last.prop('id');
															if (lastId.split('.').pop() == pop - 1|| arr.length==1) {																				
																$last.after($trHtml);											 
															}
														} else if ($parent.length == 1 && pop == '1') {
															$parent.after($trHtml);
														}							
													}
												}
											});
											$contractList.append($html);
										}					
									}else if(types=='2'){//合同类型为分包合同				
										//分包合同名称带出确权模式
										if(result.incaeSureVo.sureType=='1'){
											//带出整体下浮明细
											var details =result.incaeSureVo.incaeSureSubVos;
											if(details!=null&&details!=''&&details.length>0){
												var hash = {},subList=[];
												for(var k=0;k<details.length;k++){
													for(var i = 0, j = details[k].incaeSureDetails.length; i < j; i++) {												
														var e = details[k].incaeSureDetails[i];						
														if(typeof(hash[e.sureSubId])=='undefined'){
															hash[e.sureSubId] = subList.length;							
															subList.push({
																subName:details[k].subName,
																sureSubId:e.sureSubId,
																list:[{
																	subRowId : e.orderIdx.indexOf(',')!=-1?e.orderIdx.split(',')[1]:e.orderIdx,
																	costType : e.typeName.indexOf(',')!=-1?e.typeName.split(',')[1]:e.typeName,
																	incontractfee : e.inAfterAmount,
																	declaredfee : e.applyPreAmount,
																	incaesurefee : e.monthPreAmount,
																	notdownfee : e.notDownAmount,
																	indiscount : e.inDownRate,
																	incaesurefeeafter : e.monthAfterAmount,
																	klincaesurefeeafter : e.addupAfterAmount,
																	histroycaesurefeeafter : e.addupAfterAmount-e.monthAfterAmount
																}]
															});							

														}else{								
															var index =  hash[e.sureSubId].toString().toInt();
															subList[index].list.push({
																subRowId : e.orderIdx.indexOf(',')!=-1?e.orderIdx.split(',')[1]:e.orderIdx,
																costType : e.typeName.indexOf(',')!=-1?e.typeName.split(',')[1]:e.typeName,
																incontractfee : e.inAfterAmount,
																declaredfee : e.applyPreAmount,
																incaesurefee : e.monthPreAmount,
																notdownfee : e.notDownAmount,
																indiscount : e.inDownRate,
																incaesurefeeafter : e.monthAfterAmount,
																klincaesurefeeafter : e.addupAfterAmount,
																histroycaesurefeeafter : e.addupAfterAmount-e.monthAfterAmount
															});						
														}						
													}
												}
											}
																										
											for (var i = 0, j = subList.length; i < j; i++) {
												var itemNameSub = subList[i].subName,subId = subList[i].sureSubId;
												var tempHtml = layuiRowHtml.format(subId,itemNameSub);
												var $html = $(tempHtml);
												subList[i].list.forEach(function(e) {
													var subRowId = e.subRowId;
													var costType = e.costType;					
													var incontractfee = e.incontractfee;
													var declaredfee = e.declaredfee;
													var incaesurefee = e.incaesurefee;
													var notdownfee = e.notdownfee;
													var indiscount = e.indiscount;
													var incaesurefeeafter = e.incaesurefeeafter;
													var klincaesurefeeafter = e.klincaesurefeeafter;
													var histroycaesurefeeafter =e.histroycaesurefeeafter;
													
													var $row = $html.find('tr[id$="' + subId + 'Row-' + subRowId + '"]');
													if ($row.length == 1) {
														$row.find('input[type="hidden"]:eq(0)').val(subRowId);
														var $typeNames = $row.find('td:eq(1) input.typeNames');									
														if ($typeNames.val() != costType) {						
															$typeNames.val(costType);								
															var $lastPrev = $typeNames.prevAll(':last');
															$lastPrev.text(costType);
														}							
														$row.find('td:eq(2) input').val(incontractfee);
														$row.find('td:eq(3) input').val(declaredfee);
														$row.find('td:eq(4) input').val(incaesurefee);
														$row.find('td:eq(5) input').val(notdownfee);
														$row.find('td:eq(6) input').val(indiscount);
														$row.find('td:eq(7) input').val(incaesurefeeafter);
														$row.find('td:eq(8) input.klincaesurefeeafter').val(klincaesurefeeafter);
														$row.find('td:eq(8) input.histroycaesurefeeafter').val(histroycaesurefeeafter);
													} else {
														var arr = subRowId.split('.');
														var level = arr.length;
														if (level >= 2) {									
															var id = "sub"+subId+"Row-"+subRowId;												
															var types = subRowId.split('.');        
													        var feeTypes = types[0],feeSmallTypes = types[0]+'.'+types[1];								        												
															var $trHtml = $($('#layui-row-tr').html().format(id,level,subRowId,subId,costType,feeTypes,feeSmallTypes,itemNameSub,
																incontractfee,declaredfee,incaesurefee,notdownfee,indiscount,incaesurefeeafter,klincaesurefeeafter,histroycaesurefeeafter));
															
															var pop = arr.pop();
															var parent = arr.length==1? subId + 'Row-' + arr[0]:"sub" + subId + "Row-" + arr.join('.');								
															var siblings = (parent.indexOf('sub')==-1?'sub':'') + parent + '.';								
															var $parent = $html.find("tr[id='" + parent + "']");
															var $siblings = $html.find("tr[id^='" + siblings + "']");								
															var siblingslen = $siblings.length;							
															setReadonly($parent);
																							
															if (siblingslen > 0) {
																var $last = $($siblings[siblingslen - 1]);
																var lastId = $last.prop('id');
																if (lastId.split('.').pop() == pop - 1|| arr.length==1) {																				
																	$last.after($trHtml);											 
																}
															} else if ($parent.length == 1 && pop == '1') {
																$parent.after($trHtml);
															}							
														}
													}
												});
												$contractList.append($html);
											}
											
										}else if(result.incaeSureVo.sureType=='2'){
											//带出清单模式明细
											var listModeData = [];	
											for(var i = 0;i < result.incaeSureVo.incaeSureLists.length; i++) {												
												var e = result.incaeSureVo.incaeSureLists[i];						
												listModeData.push({
													name:e.subName,
													unit:e.subUnit,
													contractprice:e.cotUnitPrice,
													contractamount:e.cotSumPrice,
													declarednum:e.applyNums,
													declaredamount:e.applyAmount,
													incaesurenum:e.sureNums,
													samemonthincaesureamount:e.monthSureAmount,
													kaileiincaesureamount:e.addupSureAmount,
													hisotryprice:e.addupSureAmount-e.monthSureAmount
												});							
											}
										}
									}
									var type = $('#rightconfirmationmode').val(),$contractPriceInfo = $('.contract-price-info');						
									if(type=='清单模式'){
										$('.contract-price-info:first').css('display','none');
										$('.contract-price-info:last').css('display','block');						
										$('#incaesurefeeafter').removeAttr('name')
										$('#klincaesurefeeafter').removeAttr('name')
										$("#samemonthincaesureamount").attr("name","monthAfterAmount");
										$("#kaileiincaesureamount").attr("name","addupAfterAmount");
										listModeDataBind($,listModeData);
									}						
									if(type=='整体下浮'){
										$('.contract-price-info:first').css('display','block');
										$('.contract-price-info:last').css('display','none');
										$('#samemonthincaesureamount').removeAttr('name')
										$('#kaileiincaesureamount').removeAttr('name')
										$("#incaesurefeeafter").attr("name","monthAfterAmount");
										$("#klincaesurefeeafter").attr("name","addupAfterAmount");
										incaeSureAdd($);
									}					
									countTopRows($, ['incontractfee']);	
									form.render();
								}
							}
						});
						
						form.on('submit(addInfo_form_submit)', function(data) {
							$("#addInfo_form_submit").removeAttr("lay-submit").removeClass("layui-bg-blue").addClass("layui-btn-disabled");
							//提交 Ajax 成功后，静态更新表格中的数据
		                   	
		                   	$.ajax({
		                       	type : 'post',
		            			url : basePath + '/incaeSure/save',
		                       	data: $('#addInfo_form').serialize(),
		            			success:function(result){
		            				if(result.success){
		            					layer.closeAll('loading'); //关闭loading
		            					layer.msg('提交单据成功~',{icon: 1});
		            					//两秒后关闭当前页面
		            					setTimeout(function(){
		            						/**
		            						 * 查找父菜单，并刷新
		            						 */
		            						var topDoc = $(window.top.document);
		            						var path = basePath + '/incaeSure/list';
		            						// 获取页面名称
		            						var name = topDoc.find(".layui-nav-item [lay-href^='" + path + "']").text();
		            						if(name == '' || name == null){
		            							name = '对内建安产值确权';
		            						}
		            						window.parent.layui.index.openTabsPage(path, name);
		            						var iframe = window.parent.layui.admin.tabsBody(window.parent.layui.admin.tabsPage.index).find(".layadmin-iframe");
		            						iframe[0].contentWindow.location.reload(true);
		            						
		            						/**
		            						 * 关闭当前页
		            						 */
		            						var currPath = basePath + '/incaeSure/toCopy';
		            						var layid = topDoc.find("li[lay-id^='" + currPath + "']").attr('lay-id');
		            						window.parent.layui.element.tabDelete('layadmin-layout-tabs', layid);//关闭当前页
		            				        }, 2000);
		            				}else{
		            					layer.closeAll('loading'); //关闭loading
		              					$("#addInfo_form_submit").removeClass("layui-btn-disabled").addClass("layui-bg-blue").attr("lay-submit","");
		            					layer.msg(result.msg,{icon: 7});
		            			  	}
		            			}
		                   	});
						});
						
					});
	
	var incaesurefee = function(type,$tr){
		if(type=='incaesurefee' ||type=='indiscount' || type=='notdownfee'){
			var incaesurefee = $tr.find(".incaesurefee").val().toFloat();
			var notdownfee = $tr.find(".notdownfee").val().toFloat();
			var $indiscount = $tr.find(".indiscount"),indiscount = $indiscount.val().toFloat()*0.01;
			var $incaesurefeeafter = $tr.find(".incaesurefeeafter");
			var incaesurefeeafter = notdownfee + (incaesurefee-notdownfee) * (1-indiscount);
			$incaesurefeeafter.val(incaesurefeeafter.toMoney());
			
			var histroycaesurefeeafter = $tr.find(".histroycaesurefeeafter").val().toFloat(),$klincaesurefeeafter = $tr.find(".klincaesurefeeafter"),
			klincaesurefeeafter = incaesurefeeafter + histroycaesurefeeafter;
			$klincaesurefeeafter.val(klincaesurefeeafter.toMoney());														
		}
	}
	//通过第三级计算第二级的当月对内确权金额和开累对内确权金额总计
	var incaesurefee2 = function(type,$tr,$childTr){
		var incaesurefeeafter = 0;
		var klincaesurefeeafter = 0;
		var $ = layui.$;
		$childTr.find(".incaesurefeeafter").each(function(index,obj){
			if(type=='incaesurefee' ||type=='notdownfee'){
				if($(obj).val()==undefined||$(obj).val()==''||isNaN($(obj).val())){
					var thisincaesurefeeafter = 0;
					incaesurefeeafter = parseFloat(incaesurefeeafter) + parseFloat(thisincaesurefeeafter);	
				}else{
					incaesurefeeafter = parseFloat(incaesurefeeafter) + parseFloat($(obj).val());	
				}														
			}
		})
		$childTr.find(".klincaesurefeeafter").each(function(index,obj){
			if(type=='incaesurefee' || type=='notdownfee'){
				if($(obj).val()==undefined||$(obj).val()==''||isNaN($(obj).val())){
					var thisklincaesurefeeafter = 0;
					klincaesurefeeafter = parseFloat(klincaesurefeeafter) + parseFloat(thisklincaesurefeeafter);	
				}else{
					klincaesurefeeafter = parseFloat(klincaesurefeeafter) + parseFloat($(obj).val());	
				}																		
			}
		})
		$tr.find(".incaesurefeeafter").val(incaesurefeeafter.toFixed(2));
		$tr.find(".klincaesurefeeafter").val(klincaesurefeeafter.toFixed(2));
	}
	//通过第二级计算第一级的当月对内确权金额和开累对内确权金额总计
	var incaesurefee3 = function(type,$tr,$parentTr){
		var incaesurefeeafter = 0;
		var klincaesurefeeafter = 0;
		var $ = layui.$;
		$parentTr.find(".incaesurefeeafter").each(function(index,obj){
			if(type=='incaesurefee' || type=='notdownfee'){
				if($(obj).val()==undefined||$(obj).val()==''||isNaN($(obj).val())){
					var thisincaesurefeeafter = 0;
					incaesurefeeafter = parseFloat(incaesurefeeafter) + parseFloat(thisincaesurefeeafter);	
				}else{
					incaesurefeeafter = parseFloat(incaesurefeeafter) + parseFloat($(obj).val());	
				}											
			}
		})
		$parentTr.find(".klincaesurefeeafter").each(function(index,obj){
			if(type=='incaesurefee' ||type=='notdownfee'){
				if($(obj).val()==undefined||$(obj).val()==''||isNaN($(obj).val())){
					var thisklincaesurefeeafter = 0;
					klincaesurefeeafter = parseFloat(klincaesurefeeafter) + parseFloat(thisklincaesurefeeafter);	
				}else{
					klincaesurefeeafter = parseFloat(klincaesurefeeafter) + parseFloat($(obj).val());	
				}												
			}
		})
		$tr.find(".incaesurefeeafter").val(incaesurefeeafter.toFixed(2));
		$tr.find(".klincaesurefeeafter").val(klincaesurefeeafter.toFixed(2));
	}
	var incaeSureAdd = function($){
		var $contractList = $('.contract-list');				
		$contractList.on('keyup','.decimal', function() {
			var val = this.value.replace(/^(\-)*(\d+)\.(\d\d).*$/, '$1$2.$3');
			var val2 = val.replace(/[^0-9.]/g, "");
			this.value = val2;
		}).on('blur','.layui-row .contract-money input[type=text]:not([readonly].decimal)', function() {
			if($(this).val() == ''){
				return;
			}
			var $tr = $(this).parents('tr');
			var type, id;
			type = $(this).prop('class')
					.replace('layui-input', '')
					.replace('decimal', '')
					.trim();					
			id = $tr.prop("id");
			
			if(!$(this).hasClass("typeNames") && !$(this).hasClass("indiscount")){
				arabiaToCN(this,1);
			}
			
			incaesurefee(type,$tr);		
			parentGroup($, type, id);
		});
	}
	
	
	var listModeDataBind = function($,data){		
		var $table = $('#list-mode').find('tbody');		
		var template = $('#list-mode-tr').html();
		$table.empty();		
		$table.on('keyup','.decimal', function() {
			var val = this.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
			var val2 = val.replace(/[^0-9.]/g,"");
			this.value = val2;
		}).on('keyup','.integer', function() {
			var val = this.value.replace(/^(\-)*([1-9]\d*)\.(\d\d).*$/,'$2');
			var val2 = val.replace(/[^0-9.]/g,"");
			this.value = val2;
		}).on('blur','input[type=text]', function() {
			var type = $(this).prop('class').replace('decimal','').replace('layui-input','').trim();
			var $tr = $(this).parents('tr');
			if(['contractprice','declarednum','incaesurenum'].indexOf(type)!=-1){
				sumPrice($tr);
			}
			var $total = $('#'+type);
			var total = $table.find("input[type=text]."+type).inputTotal();
			$total.val(total);
			if(type=='declarednum'){
				countTopRows($,['declaredamount']);
			}else if(type=='incaesurenum'){
				countTopRows($,['samemonthincaesureamount','kaileiincaesureamount']);
			}
		});
		
		for(var i=0,j=data.length;i<j;i++){
			var html=[],rowId=i+1;
			var item = data[i];
			var rowHtml = template.format(rowId,item.name,item.unit,item.contractprice,item.contractamount,
					item.declarednum,item.declaredamount,item.incaesurenum,item.samemonthincaesureamount,
					item.kaileiincaesureamount,item.hisotryprice);
			var $rowHtml = $(rowHtml);
			sumPrice($rowHtml);
			$table.append($rowHtml);
		}

		function sumPrice($tr){			
			var $contractprice = $tr.find('.contractprice'),contractprice = $contractprice.val().toFloat(),
			$declarednum = $tr.find('.declarednum'),declarednum = $declarednum.val().toFloat(),
			$incaesurenum = $tr.find('.incaesurenum'),incaesurenum = $incaesurenum.val().toFloat(),
			$declaredamount = $tr.find('.declaredamount'),
			$samemonthincaesureamount = $tr.find('.samemonthincaesureamount'),
			$kaileiincaesureamount = $tr.find('.kaileiincaesureamount'),
			$hisotryprice = $tr.find('.hisotryprice');
			
			var declaredamount = contractprice * declarednum;			
			$declaredamount.val(declaredamount.toMoney());
			
			var samemonthincaesureamount = contractprice * incaesurenum;
			$samemonthincaesureamount.val(samemonthincaesureamount.toMoney());
			
			var kaileiincaesureamount = samemonthincaesureamount + $hisotryprice.val().toFloat();
			$kaileiincaesureamount.val(kaileiincaesureamount.toMoney());			
		}
		
		function countTopRows($, types) {
			types.forEach(function(e) {
				var $total = $('#' + e);
				var total = $table.find("input[type=text]." + e).inputTotal();
				$total.val(total);
				if(e=='samemonthincaesureamount'){
					$('#id_monthAfterAmount').val(total);
				}
				if(e=='kaileiincaesureamount'){
					$('#id_addupAfterAmount').val(total);
				}
			});
		}
	}

	var uploadRender = function(id, upload, $) {
		upload.render({
					elem : '#' + id + '-upload-more',
					url : basePath + '/incaeSure/uploadAtt/',
					data : {
						types : id
					},
					multiple : true,
					accept : 'file',
					acceptMime : 'application/zip,application/x-rar-compressed,image/jpeg,image/png,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/pdf',
					before : function(obj) {
						layer.load();
					},
					done : function(res) {
						if (res.code > 0) {
							layer.closeAll('loading');
							return layer.msg(res.msg, {
								icon : 7
							});
						}
						if (res.entity != null && res.entity.length > 0) {
							for ( var i in res.entity) {
								var preProject = res.entity[i];
								var arr = preProject.split("|");
								var imgSrc = "";
								var suffix = arr[1].substring(arr[1]
										.lastIndexOf(".") + 1, arr[1].length);
								if (suffix == 'jpg' || suffix == 'png') {
									imgSrc = "${fileHttpPre}/" + arr[3];
								} else {
									imgSrc = "${ctx}/resources/images/"
											+ suffix + ".jpg";
								}
								$('#' + id + '-upload-more-list')
										.append(
												'<div class="layui-upload-img-div" id="upload_img_'+arr[2]+'"><img src="'+imgSrc+'" title="'+ arr[1] +'" class="layui-upload-img"><div class="mask"><a href="javascript:void(0)" onclick="showImg(\''
														+ "${fileHttpPre}"
														+ arr[3]
														+ '\');">查看</a><a href="javascript:void(0)" onclick="del(\''
														+ arr[2]
														+ '\')";>删除</a></div><p>'
														+ arr[1]
														+ '</p><input type="hidden" value="'+preProject+'" id="fileAtt_'+arr[2]+'" name="fileAtts'+id+'" ></input></div>');
							}
						}
					},
					allDone : function(obj) {
						layer.closeAll('loading');
					},
					error : function() {
						layer.closeAll('loading');
						layer.msg("上传失败，请稍后再试~", {
							icon : 7
						});
					}
				});
	}
	//删除文件
	function del(index) {
		layui.$("#fileAtt_" + index).remove();
		layui.$("#upload_img_" + index).remove();
	}

	//根据url查看文件
	function showImg(url) {
		var openWin = window.open(url,'','left=410,height=768, width=1024, top=200,  toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no');
	}

	//'请输入正确数字，且保留两位小数！'
	function isNumberAndFloat2(str) {
		var rgx = /^([-]?)([0-9](\d+)?(\.\d{1,2})?$)|(^\d\.\d{1,2}$)/;
		var boolrgx = rgx.test(str);// true 
		if (boolrgx) {
			return true;
		} else {
			return false;
		}
	}

</script>